<?php 
require_once '../include.php';

$keywords=$_REQUEST['keywords']?$_REQUEST['keywords']:null;
$where=$keywords?"where concat_ws(' ',a.name,a.name2,a.region,a.description) like '%{$keywords}%'":null;

// $sql="select a.*,b.prov_name 
// from public.user a 
// join public.region b 
// on a.area_code=b.prov_code
// {$where}
// ";
//order by a.name desc,b.prov_code asc  limit {$pageSize}
// var_dump($sql);

//$sql="select * from sde.lakes a {$where}";
$sql="select * from public.tb01 a {$where}";

//$GLOBALS["DB_HOST12345"] = "gis25.jlu3s.com";
//echo $GLOBALS["DB_HOST12345"];
// var_dump($GLOBALS["DB_HOST12345"]);
//var_dump($DB_HOST);
//var_dump($DB_NAME);

//$PG = new pgsql("01.jlu3s.com", "5432", "mygdb_t1", "sde", "52GIS915");  

$PG = new pgsql($DB_HOST, $DB_PORT, $DB_NAME, $DB_USERNAME, $DB_PASSWORD);  
$PG->connect(); 
if(!$PG){ 
	$db_error = "无法连接到PostGreSQL数据库！"; echo $db_error; 
}else{  
    $rows = $PG->fetchAll($sql);
	//var_dump($rows);
	//if(is_null($rows)){ echo "未查到相关数据";}else{ foreach($rows as $row):echo $row['prov_name'];endforeach;}
	//echo $rows;
	echo json_encode($rows);
    //if(is_null($rows)){ echo "未查到相关数据";}else{ foreach($rows as $row):echo $row['remark'];endforeach;}
}


?>